// 车险缴费通过
import Vue from 'vue'
import {store} from '@/store/index'
import carPriceList  from '@/components/ivew_components/car_price_list/index.vue'
import carPriceListMods  from '@/components/ivew_conf/car_price_list_mods'
import commonFn from './common_fn.ts'


let vueObj:any = new Vue();

const  examinePass = {

    title: '支付通过',
    icon: 'icon-also-loan',
    pag: 'examinePass',
    fn (){
        let orderData = store.state['carFormStore']['orderData'];
        
        let priceData = {
            
            jqPrice: orderData.SDjqAmount,
            syPrice: orderData.SDsyAmount,
            tax: orderData.SDtaxAmount,
            payment: orderData.SDpaidMethod,
            qrCodeUrl: '',
            posCode: '',
            payId: '',
            
        }
        
        let mods = carPriceListMods(true);
        mods.forEach(mod =>{
           
            mod.conf.disabled = true;
            
        })
        
        vueObj.$Modal.confirm(
            {   
                onOk (){

                    // 取两位小数
                    store.dispatch('request', {
                        url: 'patch/order/id/status',
                        data: {

                            // 修改流程,
                            currentAction: '待缴费',
                            qrCodeUrl: priceData.qrCodeUrl,
                            posCode: priceData.posCode,
                            payId: priceData.payId,

                        }
                    }).then(success =>{


                        if(success){
                            vueObj.$Notice.success({
                                title: '提交成功'
                            })
                
                            setTimeout(() =>{
                                commonFn('updateTable','outForm')
                            }, 500)
                            
                        }
                        
                        
                    })
                    
                  
                },
                render (h){
                    return h(carPriceList, {
                        props:{
                            data: priceData,
                            hasPayment:true,
                            mods,
                        }
                    })
                }            
            }
        )
    }

}

export default examinePass